<template>
<PCard class="collection-method-con" :isCardBorder="true" :isHeadBottomBorder="false" :shadow="'never'" :bodyStyle="{width: '100%'}">
    <!-- <div slot="header" class="card-title">
      <span class="title">dddddd</span>
    </div> -->

    <div class="body">
      <a-card >

        <a-radio-group v-model="param.taxMode" style="width: 100%;">


          <a-card-grid style="width:10%;text-align:left" :hoverable="false">
            <div class="card-grid-cont h1">
              征收方式
            </div>
          </a-card-grid>
          <a-card-grid style="width:30%;text-align:left" :hoverable="false">
            <div class="card-grid-cont h1">
              <a-radio :value="1" :disabled="disabledList.disabled1">查账征收</a-radio>
            </div>
          </a-card-grid>
          <a-card-grid style="width:30%;text-align:left" :hoverable="false">
            <div class="card-grid-cont h1">
              <a-radio :value="2" :disabled="disabledList.disabled2">
                  核定征收-双定
                <!-- <a-badge :count="'推荐'" :offset="[10,-10]">
                </a-badge>-->
              </a-radio>
            </div>
          </a-card-grid>
          <a-card-grid style="width:30%;text-align:left" :hoverable="false">
            <div class="card-grid-cont h1">
              <a-radio :value="3" :disabled="disabledList.disabled3">核定征收-征收率</a-radio>
            </div>
          </a-card-grid>
          <!-- <a-card-grid style="width:25%;text-align:left" :hoverable="false">
            <div class="card-grid-cont h1">
              <a-radio :value="4" disabled >核定征收-应纳税所得率</a-radio>
            </div>
          </a-card-grid> -->
        </a-radio-group>


        <a-card-grid style="width:10%;text-align:center" :hoverable="false">
          <div class="card-grid-cont h2">说明</div>
        </a-card-grid>
        <a-card-grid style="width:30%;text-align:left" :hoverable="false">
          <div class="card-grid-cont h2">适用于企业</div>
        </a-card-grid>
        <a-card-grid style="width:30%;text-align:left" :hoverable="false">
          <div class="card-grid-cont h2">
            不具备建账建制条件（能力）的个体工商户<br /><br />
            &emsp;月收入不超过6.8万元<br />
            <!-- 20231103 双定模式用户，月开票额度字段后方金额修改为展示固定文字：“增值税、个人所得税双免政策额度内” -->
            <!-- &emsp;月收入不超过7.8万<br /> -->
            <!-- &emsp;月收入不超过增值税、个人所得税双免政策额度<br /> -->
          </div>
        </a-card-grid>
        <a-card-grid style="width:30%;text-align:left" :hoverable="false">
          <div class="card-grid-cont h2">
            不具备建账建制条件（能力）的个体工商户<br /><br />
            &emsp;年开票不超过470万<br />
          </div>
        </a-card-grid>
        <!-- <a-card-grid style="width:25%;text-align:left" :hoverable="false">
          <div class="card-grid-cont h2">
            适用于个体工商户<br />
            &emsp;年收入不超过500万
          </div>
        </a-card-grid> -->




      </a-card>
      <div class="btn-group">
        <!-- <Tips v-if="tipsConfig.tips!=''" :tips="tipsConfig.tips"></Tips> -->
        <p-Tips v-if="tipsConfig.tips!=''" v-bind="tipsConfig" ></p-Tips>
        <a-button type="primary" block @click="btnEvent"> 确 定</a-button>
      </div>
    </div>
    <div class="btn-group">
    </div>
  </PCard>
</template>

<script>
import getDataForDB from '@/api/qsbBusinessManagement'
// import Tips from './tips.vue'
export default {
  name:'CollectionMethod',
  // components:{Tips},
  props:{
    dataInfo:{type:Object},
    closeEvent:{type:Function}
  },
  data(){
    return {
      tipsConfig:{
        tips:'',
        type:'info'
      },
      param:{
        taxMode:null,
        id:''
      },
      disabledList:{
        disabled1:false,
        disabled2:false,
        disabled3:false,
        disabled4:true,
      }
    }
  },
  watch: {
    dataInfo: {
      handler(val) {
        if(this.isType.isObject(val)&&!this.isType.isEmpty(val)){
          const {tipsConfig,dataTips,data} = val
          this.tipsConfig = tipsConfig
          this.param.id = data.taxId
          if(!this.isType.isNullOrUnDef(data.serviceModelAry) && !this.isType.isEmpty(data.serviceModelAry)){
            // 1、“征收模式”选择弹层中，不再默认勾选“双定”模式
            // 2、默认勾选当前企业所选服务模式适用的征收方式
            // 3、若当前企业所选的服务模式适用多个征收方式时，不勾选任何项
            // if(data.serviceModelAry.length==1){
            //   // 核定方式数组 1-查账征收2-核定征收-双定3-核定征收-征收率4-核定征收-应纳税所得率
            //   this.param.taxMode = data.serviceModelAry[0]
            //   this.disabledList = {
            //     disabled1:false,
            //     disabled2:false,
            //     disabled3:false,
            //     disabled4:true,
            //   }
            // }
            // if(data.serviceModelAry.length>1){
            //   const temp = [1,2,3]
            //   temp.forEach(item => {
            //     if(data.serviceModelAry.indexOf(item)<0){
            //       this.disabledList[`disabled${item}`] = true
            //     }else{
            //       this.disabledList[`disabled${item}`] = false
            //     }
            //   });
            // }
            const temp = [1,2,3]
              temp.forEach(item => {
                if(data.serviceModelAry.indexOf(item)<0){
                  this.disabledList[`disabled${item}`] = true
                }else{
                  this.disabledList[`disabled${item}`] = false
                }
              });
              if(data.serviceModelAry.length==1){
                this.param.taxMode = data.serviceModelAry[0]
              }
          }
        }
      },
      deep: true,
      immediate: true
    },
  },
  methods: {
    btnEvent(){
      // this.closeEvent(this.dataInfo.closeEventType)
      if(this.isType.isNullOrUnDef(this.param.taxMode) || this.isType.isEmpty(this.param.taxMode) ){
        this.$message.warning('请选择一个征收方式')
        return false
      }
      getDataForDB('税务登记,税种确认',this.param).then(res=>{
        if(res.code===200){
          this.$message.success('保存成功')
          if(this.dataInfo.data.continue === true){
            this.closeEvent(this.dataInfo.closeEventType)
          }else{
            this.closeEvent('Refresh')
          }
        }
        if(res.code!==200){
          this.$message.error(res.message)
        }
      })
    },
  },
}
</script>

<style lang="less">
.collection-method-con{

  .body{
    width: 100%;
    height: 100%;
    overflow: auto;
    .ant-card-grid{
      // width: 100%;
      // height: 80px;
      padding: 5px 10px;
      .card-grid-cont{
        display:flex;
        justify-content: center;
        align-items: center;
      }
      .h1{
        height: 80px;
      }
      .h2{
        height: 300px;
      }
    }
  }
}
</style>
